/**
 * 
 */
package com.demo2do.boyle.common.entity.advertisement;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 
 * 广告投放标签表
 * 
 * @author Leo
 */
@Entity
@Table(name = "advertisement_tag")
public class AdvertisementTag {

	@Id
	@GeneratedValue
	private Integer id;
	 
	@OneToOne(fetch = FetchType.LAZY)
	@PrimaryKeyJoinColumn
	@JSONField(serialize = false)
    private Advertisement advertisement;
    
    private int lifeTag;
    
    private int interestTag;
    
    private int areaTag;
    
    private int sexTag;
    
    private int ageTag;
    
    /**
	 * The default cunstructor
	 */
	public AdvertisementTag() {
		
	}

	/**
     * @return the life tag value list
     */
    public List<String> getStringLifeTagCodes() {
    	List<String> tagCodes = new ArrayList<String>();
		for(Integer pow = 1; pow != 0; pow <<= 1) {
			if((this.lifeTag & pow) != 0) {
				tagCodes.add(pow.toString());
			}
		}
		return tagCodes;
    }
    
    /**
     * @return the interest tag value list
     */
    public List<String> getStringInterestTagCodes() {
    	List<String> tagCodes = new ArrayList<String>();
		for(Integer pow = 1; pow != 0; pow <<= 1) {
			if((this.interestTag & pow) != 0) {
				tagCodes.add(pow.toString());
			}
		}
		return tagCodes;
    }
    
    /**
	 * @return the sexTag
	 */
	public List<String> getStringSexTag() {
    	List<String> tagCodes = new ArrayList<String>();
		for(Integer pow = 1; pow != 0; pow <<= 1) {
			if((this.sexTag & pow) != 0) {
				tagCodes.add(pow.toString());
			}
		}
		return tagCodes;
    }
	
	/**
	 * @return the areaTag
	 */
	public List<String> getStringAreaTag() {
    	List<String> tagCodes = new ArrayList<String>();
    	if (this.areaTag == 0) {
    		tagCodes.add(String.valueOf(0));
		} else {
			for(Integer pow = 1; pow != 0; pow <<= 1) {
				if((this.areaTag & pow) != 0) {
					tagCodes.add(pow.toString());
				}
			}
		}
		return tagCodes;
    }
	
	/**
	 * @return the ageTag
	 */
	public List<String> getStringAgeTag() {
    	List<String> tagCodes = new ArrayList<String>();
		for(Integer pow = 1; pow != 0; pow <<= 1) {
			if((this.ageTag & pow) != 0) {
				tagCodes.add(pow.toString());
			}
		}
		return tagCodes;
    }
    
	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @return the advertisement
	 */
	public Advertisement getAdvertisement() {
		return advertisement;
	}

	/**
	 * @return the lifeTag
	 */
	public int getLifeTag() {
		return lifeTag;
	}

	/**
	 * @return the interestTag
	 */
	public int getInterestTag() {
		return interestTag;
	}

	/**
	 * @return the areaTag
	 */
	public int getAreaTag() {
		return areaTag;
	}

	/**
	 * @return the sexTag
	 */
	public int getSexTag() {
		return sexTag;
	}

	/**
	 * @return the ageTag
	 */
	public int getAgeTag() {
		return ageTag;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @param advertisement the advertisement to set
	 */
	public void setAdvertisement(Advertisement advertisement) {
		this.advertisement = advertisement;
	}

	/**
	 * @param lifeTag the lifeTag to set
	 */
	public void setLifeTag(int lifeTag) {
		this.lifeTag = lifeTag;
	}

	/**
	 * @param interestTag the interestTag to set
	 */
	public void setInterestTag(int interestTag) {
		this.interestTag = interestTag;
	}

	/**
	 * @param areaTag the areaTag to set
	 */
	public void setAreaTag(int areaTag) {
		this.areaTag = areaTag;
	}

	/**
	 * @param sexTag the sexTag to set
	 */
	public void setSexTag(int sexTag) {
		this.sexTag = sexTag;
	}

	/**
	 * @param ageTag the ageTag to set
	 */
	public void setAgeTag(int ageTag) {
		this.ageTag = ageTag;
	}
	
}